package com.bob.idea.action;

import com.bob.common.DataStore;
import com.bob.idea.common.Constant;
import com.bob.idea.gui.MainFrame;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.CommonDataKeys;
import com.intellij.openapi.actionSystem.DataKey;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vcs.VcsDataKeys;
import com.intellij.openapi.vcs.history.VcsRevisionNumber;

import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;


/**
 * 提取增量补丁文件
 */
public class GitCommitAction extends AnAction {


    public void actionPerformed(AnActionEvent e) {
        DataKey<VcsRevisionNumber[]> vcsRevisionNumbers = VcsDataKeys.VCS_REVISION_NUMBERS;
        VcsRevisionNumber[] revisionNumbers =  e.getData(VcsDataKeys.VCS_REVISION_NUMBERS);
        List<String> var10000 = revisionNumbers != null ? Arrays.asList(revisionNumbers).stream().map(VcsRevisionNumber::asString).collect(Collectors.toList()) : Collections.emptyList();
        var10000.forEach((i)->{
            System.out.println(i);
        });
        DataStore.getDataStore().getData().put(Constant.CACHE_KEY_visionNumbers,var10000);
        Project project = (Project)e.getData(CommonDataKeys.PROJECT);
        UpgradeMojo.exec(project.getBasePath());
        // 初始化主窗口
        MainFrame.getMainFrame().init();
    }
}
